<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Kowcore
 * @copyright  Copyright KEENONWEB LLC
 * @license    http://www.keenonweb.com/
 * @version    $Id: RatersFluentList.php 2011-03-09 08:45:41Z idris $
 * @author     Idris
 */

/**
 * @category   Application_Extensions
 * @package    Kowcore
 * @copyright  Copyright KEENONWEB LLC
 * @license    http://www.keenonweb.com/
 */

class Kowcore_View_Helper_RatersFluentList extends Zend_View_Helper_Abstract {
	
	protected $_name;
	
	public function ratersFluentList(Core_Model_Item_Abstract $object) {
		if (! $object->getIdentity ()) {
			return '';
		}
		
		$table = Engine_Api::_ ()->getDbTable ( 'rates', 'kowcore' );
		$name = $table->info ( 'name' );
		$select = $table->select ()->setIntegrityCheck ( false )->from ( $name, array ('cnt' => 'COUNT(rate_id)' ) )->where ( $name . '.object_type = ?', $object->getType () )->where ( $name . '.object_id = ?', $object->getIdentity () );
		
		$count = $table->getAdapter ()->fetchOne ( $select );
		if (! $count) {
			return '';
		}
		
		return $this->view->partial ( 'helper/raters-fluent-list.tpl', 'kowcore', array ('count' => $count, 'object' => $object ) );
	}

}